Install SpeedyCGI
2015/01/17 |
Enable SpeedyCGI and makes Perl scripts be fast.
The difference from mod_perl
is that processes of SpeedyCGI are separated from Apache's processes.
|
|
[1] | Install SpeedyCGI. |
[root@www ~]# yum --enablerepo=epel -y install perl-CGI-SpeedyCGI # install from EPEL |
[2] |
How to use ( how to write codes ).
For example, there is a test script like follows.
Replace The PATH from "#!/usr/bin/perl" to "#!/usr/bin/speedy". But Be careful to write codes. |
#!/usr/local/bin/perl use strict; use warnings; print "Content-type: text/html\n\n"; print "<html>\n<body>\n"; print "<div style=\"width:100%; font-size:40px; font-weight:bold; text-align:center;\">"; my $a = 0; &number(); print "</div>\n</body>\n</html>"; sub number { $a++; print "number \$a = $a"; } |
The result of executing the script above is like follows. The result is never change even if reloading again and again, of course. |
However, if changing the script to SpeedyCGI environment, the result is like follows, the number increases. |
As the example, under the SpeedyCGI ( Registry mode of mod_perl is also the same ) environment, because parameters are also kept in RAM, maybe the result you intent would change like this example. To get the same result under the SpeedyCGI environmet for this example, it must write like follows. Anyway, if you use SpeedyCGI or Registry mode of mod_perl or FastCGI, Be Careful to use parameters. |
#!/usr/bin/speedy use strict; use warnings; print "Content-type: text/html\n\n"; print "<html>\n<body>\n"; print "<div style=\"width:100%; font-size:40px; font-weight:bold; text-align:center;\">"; my $a = 0;
&number(
$a );print "</div>\n</body>\n</html>"; sub number { my($a) = @_; $a++; print "number \$a = $a"; } |